
/* Generated by Interface Builder */

#import <stdio.h>
#import "NumberLineView.h"
#import <appkit/Control.h>
#import <dpsclient/wraps.h>

#define LEFT_MARGIN 10.0
#define RIGHT_MARGIN 30.0

@implementation NumberLineView

+newFrame:(const NXRect *)tF {
    self = [super newFrame:tF];
    max = min = 50.0;
    return self;
}

- setMinText:anObject
{
    minText = anObject;
    return self;
}

- setMaxText:anObject
{
    maxText = anObject;
    return self;
}

- newMinValue:sender
{
	min = [sender floatValue];
	[minText setFloatValue:min];
	[self display];
    return self;
}

- newMaxValue:sender
{
	max = [sender floatValue];
	[maxText setFloatValue:max];
	[self display];
    return self;
}

- drawSelf:(NXRect*)r :(int)c
{
	char str[10];
	int i;
	float width,vert,scale;
	width = bounds.size.width-RIGHT_MARGIN-LEFT_MARGIN;
	vert = bounds.size.height/2.0;
	scale = (bounds.size.width-RIGHT_MARGIN-LEFT_MARGIN)/100.0;
    PSsetgray(NX_WHITE);
    NXRectFill(r);
    PSsetgray(NX_LTGRAY);
    PSsetlinewidth(1.0);
    PSnewpath();
    	PSmoveto(LEFT_MARGIN, vert);
    	PSrlineto(width, 0.0);
    PSstroke();
	PSsetgray(NX_DKGRAY);
    PSsetlinewidth(5.0);
	PSnewpath();
    	PSmoveto(LEFT_MARGIN+(0.0)*scale, vert);
    	PSlineto(LEFT_MARGIN+min*scale, vert);
    PSstroke();
    PSnewpath();
    	PSmoveto(LEFT_MARGIN+max*scale, vert);
    	PSlineto(LEFT_MARGIN+(100.0)*scale, vert);
    PSstroke();
	PSsetgray(NX_BLACK);
    PSselectfont("Helvetica", 16.0);
    for (i=0; i<=10; i++) {
    	sprintf(str, "%d", i*10);
		PSmoveto(10.0*scale*i+LEFT_MARGIN, 5.0);
    	PSshow(str);
	}
    return self;
}

@end
